
return {
    beforePreProcess: function (content, url) {
        //beforePreProcess 页面初始化之前，可在此进行模版修改 or 定义新的参数
       
    },
    beforePageInit: function (page) {
        var self = this
        self.tool.format= async function (products) {
            var self = this;
            let obj = {
                customer: cb.rest.appContext.context.agentId,
                deliveryMethod: '自提',
                receiveAddress: '',
                productDetail: [],
            }
            products.forEach(element => {
                let product = {
                  productCode: element.cCode,
                  productId: element.id,
                  org: element.saleOrgId,
                  priceQty: 1,
                  productUnitId: element.mainUnit.id,
                  currency: '1655486829428736015',
                  stockId: ''
                }
                obj.productDetail.push(product)
            });
            let getPrice = function(){
                return new Promise((resolve, reject) => {
                    cb.rest.postCross({
                        url: "https://saas.hlhs-bip.com/iuap-api-gateway/ajxbewdh/AcquisitionPrice/GetPriceAndFreight/pricing/acquisitionPrice?appKey=a4dc65b0fbab4f68a56e8054999a2ab3",
                        params: obj,
                        type:'post',
                        success: (res) => {
                            resolve(res.data)
                        },
                        error: function(errRes) {
                            console.log('errRes', errRes);
                        }
                    })
                })
            }
            let list = []
            if(products.length != 0) {
                list = await getPrice()
            }
            return Array.isArray(products) && products.forEach(function(item) {
                item.isHidePrice = self.context.isHidePrice,
                item.fSalePrice = upcommon.toThousands(list[item.id].price),
                item.isHidePrice ? item.iMinPrice = "***" : item.fSalePrice && "0" !== item.fSalePrice ? item.iMinPrice = item.fSalePrice : item.iMinPrice = cb.FunctionOptions && cb.FunctionOptions.PRODUCTPRICESHOW ? cb.FunctionOptions.PRODUCTPRICESHOW : 0,
                item.isShowPrice = cb.FunctionOptions && !cb.FunctionOptions.PRODUCTNOTSHOWPRICE,
                item.productTips = !0 === cb.FunctionOptions.ORDERINVENTORYCHECK && "NONE" != cb.FunctionOptions.INVENTORYDISPLAY && upcommon.showProductTips(item.productTip),
                0 < item.cName.indexOf("®") && (item.cName = item.cName.replace(/®/g, lang.templateByUuid("UID:P_UDHMC_17EC591E0588088C", "<sup>®</sup>")));
                var relation = upcommon.setCurrTypeSign(item);
                cb.rest.appContext.context.isAgent && cb.FunctionOptions.ORDERSHOWWAY && relation && 1 == relation.bizType && (item.bizName = -1 < [3, 4].indexOf(cb.rest.appContext.context.bizMode) ? item.orgName : cb.rest.appContext.context.corpName)
            }),
            products
        }
        self.tool.setAllProducts= async function(data, page) {
            var context = {};
            context.products = await this.tool.format.call(this, data ? data.data : ""),
            context.isTourist = !!cb.rest.appContext.isTourist,
            context.isOpenMultOrginazation = cb.FunctionOptions.ORDERSHOWWAY && (2 == cb.rest.appContext.context.bizMode || 4 == cb.rest.appContext.context.bizMode),
            context.products && (0 < context.products.length ? ($$(page.container).find("#newProducts").removeClass("hide"),
            $$(page.container).find("#newProducts").parent().removeClass("hide")) : ($$(page.container).find("#newProducts").addClass("hide"),
            $$(page.container).find("#newProducts").parent().addClass("hide")),
            $$(page.container).find("#newProducts").html(this.tplProductFunc(context)),
            myApp.initImagesLazyLoad($$(page.container)),
            $$.each($$(page.container).find(".upimgdiv"), function(index, item) {
                var parentWidth = $$(item).parent().width();
                $$(item).css({
                    width: parentWidth + "px",
                    height: parentWidth + "px"
                })
            }),
            myApp.refreshScroller())
        }
        self.tool.setRecommendProducts= async function(data, page) {
            var context = {};
            context.products = await this.tool.format.call(this, data ? data.data : ""),
            context.isOpenMultOrginazation = cb.FunctionOptions.ORDERSHOWWAY && (3 == cb.rest.appContext.context.bizMode || 4 == cb.rest.appContext.context.bizMode),
            context.products && (0 < context.products.length ? ($$(page.container).find("#adviceProducts").removeClass("hide"),
            $$(page.container).find("#adviceProducts").parent().removeClass("hide")) : ($$(page.container).find("#adviceProducts").addClass("hide"),
            $$(page.container).find("#adviceProducts").parent().addClass("hide")),
            $$(page.container).find("#adviceProducts").html(this.tplProductFunc(context)),
            myApp.initImagesLazyLoad($$(page.container)),
            $$.each($$(page.container).find(".upimgdiv"), function(index, item) {
                var parentWidth = $$(item).parent().width();
                $$(item).css({
                    width: parentWidth + "px",
                    height: parentWidth + "px"
                })
            }),
            myApp.refreshScroller())
        }
    },   
    afterPageInit: function (page) {
        // 该事件时  Dom已ready 但已执行当前页面固有逻辑
        console.log('lexus');
    },
    beforePageBack: function (page) {
        // 页面回退之前
    },
    afterPageBack: function (page) {
        // 页面回退之后
        if(page.fromPage.name == 'addrListPage' && page.query.acquioAddressData) {
            console.log("page.query.acquioAddressData: ", page.query.acquioAddressData)
        }
    },
};